﻿using System;
using System.Collections.Generic;
using System.Text;

namespace Utility
{
    public class StringHelper
    {
        public static string ListToString(List<string> str)
        {
            string strRet = string.Empty;
            foreach (string key in str)
            {
                strRet += string.Format(",'{0}'", key);

            }
            if (strRet.StartsWith(","))
                strRet = strRet.Substring(1);
            return strRet;
        }
        public static bool IsEmty(object obj)
        {
            if (obj == null)
                return true;
            else
            {
                return string.IsNullOrEmpty(obj.ToString().Trim());
            }
            
        }
        public static string StrStartSubstring(string data, string replace)
        {
            if (IsEmty(data))
                return string.Empty;
            if (data.Trim().StartsWith(replace))
            {
                data = data.Trim().Substring(replace.Length);
            }
            return data;
        }
        public static string StrEndSubstring(string data, string replace)
        {
            if (IsEmty(data))
                return string.Empty;
            if (data.Trim().EndsWith(replace))
            {
                data = data.Trim().Substring(0,data.Trim().Length- replace.Length);
            }
            return data;
        }
    }
}
